﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RobotBattle2.Scripting;
using System.CodeDom.Compiler;
using RobotBattle2.Utilities;

namespace RobotBattle2.Rsl2 {
	partial class Parser {
		public Script Script { get; private set; }

		partial void Error(string filename, int line, int column, int errorCode, string message) {
			Script.Errors.Add(
				new CompilerError(
					filename, line, column,
					string.Format("RSL{0:d4}", errorCode),
					message
				) { IsWarning = false }
			);
		}

		private Decimal ParseNumber(string text) {
			return Decimal.Parse(text);
		}

		private string ParseString(string text) {
			return text
				.Substring(1, text.Length - 2)
				.Unescape();
		}
	}
}
